import sys
from PyQt5.QtWidgets import QApplication, QDialog, QMainWindow
from login import LoginWindow
from main import MainWindow
from reg import RegWindow
import toml

class Controler:
    def __init__(self) -> None:
        config = toml.load("config.toml")
        self.addr = "http://"+config["ip"]+":8888"
        pass

    def show_login(self):
        self.loginWin = LoginWindow()
        self.loginWin.show_main_signal.connect(self.show_main)

        self.loginWin.show_reg_signal.connect(self.show_reg)

        self.loginWin.show()

    def show_main(self):
        self.mainWin = MainWindow(username=self.loginWin.username)
        self.mainWin.show()

    def show_reg(self):
        self.regWin = RegWindow()
        self.regWin.show()


if __name__ == "__main__":
    app = QApplication(sys.argv)

    controller = Controler()
    controller.show_login()

    sys.exit(app.exec())
